package com.example.ui.contact.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.huashangapp.R;
import com.example.ui.contact.bean.User;
import com.example.ui.leftmenu.Item08View;

/**
 * 附近的人列表适配器
 * @author Leone
 *
 */
public class NearListViewAdapter extends BaseAdapter{
	private LayoutInflater inflater;
    public List<User> list;
	public NearListViewAdapter(Context mContext ,List<User> list){
		inflater = LayoutInflater.from(mContext);
		this.list = list;
	}

	@Override
	public int getCount() {
		return Item08View.near_length;
	}

	@Override
	public Object getItem(int position) {
		return position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder = null;
		convertView=null;
		if(convertView == null){
			convertView = inflater.inflate(R.layout.chat_near_listveiw, null);
			holder = new Holder();
			//holder.img = (ImageView)convertView.findViewById(R.id.item01_list_img);
			holder.textTitle = (TextView) convertView.findViewById(R.id.item_list_text_title);//item_list_text_title  item01_list_text_title
			holder.textNum = (TextView) convertView.findViewById(R.id.distance_num); //distance_num  item01_list_text_num
        	convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }
//		TextView titleText=(TextView)view.findViewById(R.id.layout_title_middle_text);
//		titleText.setText("附近的人");
		
	//	holder.img.setBackgroundResource(near_people_imgArr[position]);
		
		//holder.textTitle.setText(Item08View.name[position]);
		//holder.textNum.setText(Item08View.distance[position]);
		
		User user = list.get(position);
		String title = user.getNick();
		String dis = user.getDistatce();
		
		holder.textTitle.setText(title);
		holder.textNum.setText(dis);
		return convertView;
	}
	
	class Holder{
		//ImageView img;
    	TextView textTitle;
    	TextView textNum;
    }
	
	
}
